Component({
    data: {
        active: 0,
        list: [{
                icon: 'home-o',
                text: '登记样品',
                url: 'index'
            },
            {
                icon: 'search',
                text: '接收样品',
                url: 'index2'
            }
        ]
    },

    methods: {
        init() {
            const page = getCurrentPages().pop();
            this.setData({
                active: this.data.list.findIndex(item => item.url ===(`/${page.route}`.split('/')[3]))
            });
        },
        onChange(event) {
            this.setData({
                active: event.detail
            });
            wx.switchTab({
                url: this.data.list[event.detail].url
            });
        }
    }
});